#include <iostream>
#include <pthread.h>
#include <string>
#include <unistd.h>
#include <vector>
#include "Thread.hpp"
#include <memory>

using namespace std;



void *thread_run(void *args)
{
    std::string work_type = static_cast<const char*>(args);
    while(true)
    {
        std::cout << "我是一个新线程，我正在做：" << work_type << std::endl;
        sleep(1);
    }
}


int main()
{
    std::unique_ptr<Thread> thread1(new Thread(thread_run,(void *)"hellothread",1));
    std::unique_ptr<Thread> thread2(new Thread(thread_run,(void *)"countthread",2));
    std::unique_ptr<Thread> thread3(new Thread(thread_run,(void *)"logthread",3));

    thread1->join();
    thread2->join();
    thread3->join();

    
    return 0;
}


// class ThreadData
// {
// public:
//     pthread_t tid;
//     char namebuffer[64];
// };



// void *start_routine(void *args)
// {
//     ThreadData *td= static_cast<ThreadData*>(args);   //安全的进行强制类型转换
//     int cnt = 10;
//     while(cnt)
//     {
//         cout << "new thread create success , name : " << td->namebuffer << "cnt : " <<  cnt-- <<  endl;
//         sleep(1);
//     }
//     delete td;
//     return nullptr;   
// }


